@include('admin.layout.bone_header')

<div class="layui-btn-container">


</div>


<table class="layui-hide" id="think-table" lay-filter="think-table"></table>

<script type="text/html" id="barDemo">

    @{{# if(d['status'] == 2){  }}
        <a class="layui-btn layui-btn-xs" lay-event="send_orders">发货</a>
    @{{# } }}
</script>

<script>

    layui.use('table', function () {
        let table = layui.table;
        UI.getPageTable(table, "{{route('admin.orders.orders')}}", [
            {field: 'orders_id', title: 'ID', width: 80, sort: true, fixed: 'left'}
            , {field: 'orders_code', title: ' 订单号'}
            , {field: 'user_id', title: ' 下单人'}
            , {field: 'address_json_data', title: ' 联系人',templet:function (d){
                    let jsonData = JSON.parse(d['address_json']);
                    return jsonData['name']+'----'+jsonData['phone'];
                }}
            , {field: 'address_json_data', title: ' 联系地址',templet:function (d){
                    let jsonData = JSON.parse(d['address_json']);
                    return jsonData['details_address'];
                }}
            , {field: 'price', title: ' 订单价格'}
            , {field: 'status', title: ' 状态',templet:function (d){
                    let arr = ['','已付款','待发货','待收货','已完成']
                    return arr[d['status']]
                }}
            ,{fixed: 'right',title:'操作', align:'center', toolbar: '#barDemo'}
        ]);

        table.on('tool(think-table)', function (obj) {
            let data = obj.data;
            if(obj.event === 'send_orders'){
                UI.openLayer("{{route('admin.orders.send_orders')}}?orders_id="+data['orders_id'],980);
            }
        });
        let $ = layui.$, active = {
            addImages:function (){
                UI.openLayer("{{route('admin.goods.add')}}",980);
            }
        };
        $('.layui-btn-container .layui-btn').on('click', function () {
            let type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        $('.search .layui-btn').on('click', function () {
            let type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    })


</script>


@include('admin.layout.bone_footer')
